#!/bin/bash
SERVER="example.com"
PORTS=(80 443 22 3306)
for port in "${PORTS[@]}"; do
  nc -zv $SERVER $port &>/dev/null && status="开放" || status="关闭"
  echo "$port: $status"
done